package com.self.smallma.myblogweb.controller;

import java.util.Arrays;
import java.util.Map;

import com.self.smallma.myblogweb.common.utils.PageUtils;
import com.self.smallma.myblogweb.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.self.smallma.myblogweb.entity.BlogTypeRelationEntity;
import com.self.smallma.myblogweb.service.BlogTypeRelationService;




/**
 * 
 *
 * @author mahuanyu
 * @email 1914096395@qq.com
 * @date 2021-07-17 17:48:05
 */
@RestController
@RequestMapping("myblogweb/blogtyperelation")
public class BlogTypeRelationController {
    @Autowired
    private BlogTypeRelationService blogTypeRelationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("myblogweb:blogtyperelation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = blogTypeRelationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("myblogweb:blogtyperelation:info")
    public R info(@PathVariable("id") Long id){
		BlogTypeRelationEntity blogTypeRelation = blogTypeRelationService.getById(id);

        return R.ok().put("blogTypeRelation", blogTypeRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("myblogweb:blogtyperelation:save")
    public R save(@RequestBody BlogTypeRelationEntity blogTypeRelation){
		blogTypeRelationService.save(blogTypeRelation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("myblogweb:blogtyperelation:update")
    public R update(@RequestBody BlogTypeRelationEntity blogTypeRelation){
		blogTypeRelationService.updateById(blogTypeRelation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("myblogweb:blogtyperelation:delete")
    public R delete(@RequestBody Long[] ids){
		blogTypeRelationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
